//
//  ViewController.m
//  7-系统自带分享
//
//  Created by J on 15/11/15.
//  Copyright © 2015年 JZJ. All rights reserved.
//

#import "ViewController.h"
#import <Social/Social.h>
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
   
////    //判断服务是否可用
    if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeSinaWeibo]) {
        
        //创建分享控制器
        
        
        SLComposeViewController * compost = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTencentWeibo];
        //设置默认数据
        
        [compost setInitialText:@"今天天气很好.只不过没出门"];
        [compost addImage:[UIImage imageNamed:@"1"]];
        
        //弹出分享控制器
        
        
        [self presentViewController:compost animated:YES completion:nil];
        
        //监听分享状态
        
        compost.completionHandler=^(SLComposeViewControllerResult result){
            
            
            if (result == SLComposeViewControllerResultCancelled) {
                NSLog(@"取消发送");
            }else{
                NSLog(@"发送成功");
                
            }
            
            
        };
        
    }
    
 
    
    }



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
